package ru.dcsearch.indexer;

/***************************************************************************
 *   Created by TMC
 *   berechitai@gmail.com
 *
 *   This file is part of DC Indexer project
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 ***************************************************************************/

public class DCClient {

	public Prefs p = new Prefs();
	public NetWorker nw;
	public NetHandler nh;
	public Userlist	 ul;
	public ClientConnectionManager cc;
    public PortsPool pp;
    public DownloadScheduler dsch;
	
	public long		DLtraffic = 0, ULtraffic = 0;
	
	public boolean	OLDTAG = false;
	public static final String version	= "0.02";
	
	public DCClient() {
		
        ul = new Userlist(this,p);
	    nh = new NetHandler(this, false);
	    nw = new NetWorker(this);
	    cc = new ClientConnectionManager(this);
        pp = new PortsPool(p);
		
	}
	
	public void beginWork() {
		
	nh.start();
	
        try {
            Thread.sleep(15000);
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        Logger.printLog("Begin work");
        dsch = new DownloadScheduler(this);
        while (true) {
            Logger.printGlobalLog("DOWNLOAD ITERATION");
            dsch.downloadWorker();
            Logger.printGlobalLog("DOWNLOAD ITERATION ENDED");
            try {
                Thread.sleep(30000);
            } catch (InterruptedException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }
    }
}
